package com.fit.pages.card;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.CoachAccess;
import com.fit.annotations.MemberAccess;
import com.fit.dao.card.CardDAO;
import com.fit.entities.card.Card;
import com.fit.pages.ErrorPage;


@AdminAccess
@CoachAccess
@MemberAccess
public class View {

	@Property
	@Persist
	private Card card;
	@Inject
	private CardDAO cardDAO;
	@InjectPage
	private ErrorPage errorPage;

	Object onActivate(Long id) {
	card = cardDAO.findByID(id);
		if (card == null) {
			errorPage.setMessage("Error in view class");
			return errorPage;
		}
		return null;

	}
}
